package com.rainyun.rd.main;

import com.rainyun.rc.command.CmdPath;
import com.rainyun.rc.ioc.BeanNotInit;
import com.rainyun.rc.ioc.Beanzy;
import com.rainyun.rc.ioc.RainIOC;
import com.rainyun.rcmc.bukkit.BukkitPlugin;
import com.rainyun.rcmc.bukkit.RainBukkitUtil;
import com.rainyun.rcmc.bukkit.annotation.BukPlugin;
import com.rainyun.rd.biz.BizRD;
import com.rainyun.rd.common.BeanRd;
import com.rainyun.rd.util.RdNmsUtil;
import org.bukkit.Bukkit;

import java.util.Map;
import java.util.logging.Logger;

@BukPlugin(name = "RainDemo", //名称
        author = {"Akr_on"}, //作者
        depend = {"RainCore"},  //依赖
        version = "1.0.0") //版本
@BeanNotInit //插件主类必需有该项
public class RainDemo extends BukkitPlugin {

    //业务
    @Beanzy
    BizRD bizRD;

    //日志
    @BeanRd(BeanRd.BeansRd.Logger)
    Logger logger;

    /**启动*/
    @Override
    public void onEnable() {
        super.onEnable();//载入类

        RainIOC.set(BeanRd.BeansRd.Logger,getLogger());
        RainIOC.set(BeanRd.BeansRd.Classloader,getClassLoader());
        //存入日志对象和类加载器

        //存入nms工具
        RainIOC.set(BeanRd.BeansRd.NmsUitl,new RdNmsUtil());

        //注册所有指令
        Map<String, CmdPath<?>> cmds = RainBukkitUtil.initAllCmd(classes, this);
        RainIOC.set(BeanRd.BeansRd.Cmds,cmds);

        //注册所有监听器
        RainBukkitUtil.initAllListener(classes, this);

        // 启动时顺便重载一下
        bizRD.reload(Bukkit.getConsoleSender());
    }

    /**关闭*/
    @Override
    public void onDisable() {
        super.onDisable();
    }
}
